<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: taohj
  Date: 2014/6/29
  Time: 18:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<c:set var="menu" value="none" scope="request"></c:set>
<!Doctype html>
<html>
<head>
    <base href="<%=basePath%>">
    <title>政府数据开放平台</title>
    <jsp:include page="../../../commons/include.jsp"/>

    <link href="/resources/css/lib.css" rel="stylesheet">

    <script type="text/javascript">
        $(function () {
            $('.pagination > li').each(function () {
                $(this).on('click', function () {
                    location.href = '/front/data/mylist?page=' + $(this).attr('page') + '&dataset=' + $('input[name=dataset]').val();
                })
            });

            $("tbody>tr").each(function () {
                var id = $(this).attr('dataid');
                console.info($(this).find('td:last>a:first'));
                $(this).find('td:last>a:first').on('click', function () {
                    location.href = '/front/data/modifyV?id=' + id;
                })

                $(this).find('td:last>a:last').on('click', function () {
                    location.href = '/front/data/remove?id=' + id;
                })
            });
        });
    </script>
</head>
<body>

<jsp:include page="../../../commons/top.jsp"/>
<div class="main">

    <jsp:include page="../../../commons/dashboardMenu.jsp"/>


    <div style="padding: 20px;">
        <input name="dataset" type="hidden" value="${result.pageResult.t.dataset.id}">
        <input type="button" value="新增"
               onclick="location.href='/front/data/createV?dataset=${result.pageResult.t.dataset.id}'">
    </div>

    <div style="padding: 20px;min-height: 400px;">
        <table class="table">
            <thead>
            <tr style="text-align: left">
                <td style="width: 40px">序号</td>
                <td style="width: 150px">标题</td>
                <td style="width: 100px">标签</td>
               <td style="width: 100px">授权信息</td>
                <td style="width: 100px">机构</td>
                <td style="width: 60px">存储形式</td>
                <td style="width: 60px">地址</td>
                <td style="width: 60px">是否公开</td>
                <td style="width: 60px">数据集</td>
                <td style="width: 100px">操作</td>
            </tr>
            </thead>

            <tbody>
            <c:forEach items="${requestScope.result.pageResult.rows}" var="data" varStatus="status">
                <tr dataid="${data.id}">
                    <td>${status.count+(requestScope.result.pageResult.page-1)*requestScope.result.pageResult.size}</td>
                    <td><a href="www.baidu.com">${data.title}</a></td>
                    <td>${data.tags}</td>
                     <td>${data.license}</td>
                    <td>${data.org.name}</td>
                    <td>${data.storage.name}</td>
                    <td><c:if test="${fn:length(data.url)>0}"><a href="${data.url}" target="_blank">查看</a> </c:if></td>
                    <td>${data.visibility.name}</td>
                    <td>${data.dataset.name}</td>
                    <td><a href="javascript:void(0)">更新</a>&nbsp; <a href="javascript:void(0)">删除</a></td>
                </tr>
            </c:forEach>

            </tbody>
        </table>
    </div>


    <div>
        <ul class="pagination" style="margin: 20px 30px;">
            <li page="${requestScope.result.pageResult.startPage-1}">&laquo;</li>

            <c:forEach begin="${requestScope.result.pageResult.startPage}"
                       end="${requestScope.result.pageResult.endPage}" var="index">
                <li page="${index}" <c:if
                        test="${index==requestScope.result.pageResult.page}"> class="active" </c:if> >${index}
                </li>
            </c:forEach>

            <li page="${requestScope.result.pageResult.endPage+1}">&raquo;</li>
        </ul>

    </div>


</body>
</html>
